/*
 * @lc app=leetcode.cn id=621 lang=javascript
 *
 * [621] 任务调度器
 */

// @lc code=start
/**
 * @param {character[]} tasks
 * @param {number} n
 * @return {number}
 */
var leastInterval = function(tasks, n) {
   const taskCount = _.countBy(tasks);
   const values = Object.values(taskCount);
   const max = Math.max(...values);
   const m = values.filter(v => v === max).length;
   return Math.max(tasks.length, (max - 1) * (n + 1) + m);
};
// @lc code=end

